/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author MINHTU
 */

import DAL.MyConnectUnit;
import DAL.MySQLConnect;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;

public class MainTest {
    public static void main (String []args) throws Exception{
       
        MySQLConnect connect = new MySQLConnect("localhost", "root", "", "cafedb");
        ResultSet result = connect.excuteQuery("Select * from NhanVien");
        System.out.println("So dong la:" + CountRow(result));
        
        result = connect.excuteQuery("Select * from NhanVien where IDNhanVien = 1");
        System.out.println("So dong la:" + CountRow(result));
        connect.Close();
        
          MyConnectUnit connectUnit = new MyConnectUnit("localhost", "root", "", "cafedb");
    
        //insert du lieu
        HashMap<String,Object> insertValues = new HashMap<String,Object>();
        insertValues.put("TenNhanVien", "Le Van Teo");
        System.out.println(connectUnit.Insert("NhanVien", insertValues));
        
        
        connectUnit.Close();
      
      
    }
    
    protected static int CountRow(ResultSet result) throws Exception{
        int count = 0;
        while (result.next()){
            count ++;
            //result.getObject("TenNhanVien");
        } 
        return count;
    }
}
